import request from '@/router/axios'
import moment from 'moment';
import { fenExYuangettoFixed,
  getLineName,
  getStationName
} from "../../../subwayRat/commonCheck";
export function getXw_bom_shouJieSuan_waitSubmit(query) {
  let longSearch = query.longSearch;
  if (longSearch == 1) {
    query.endSettleDate = moment(query.endSettleDate).add(1, 'days').format("YYYY-MM-DD") + " 01:59:59";
    //query.endTime = query.endSettleDate;
  }
  return request({
    url: '/check/xw_js_bom/getXw_bom_shouJieSuan_waitSubmit',
    method: 'post',
    params: query
  })
}

export function getXw_bom_shouJieSuan_for_waitSubmit(query) {
  return request({
    url: '/check/xw_js_bom/getXw_bom_shouJieSuan_for_waitSubmit',
    method: 'post',
    params: query
  })
}

export function bomForSubmit(query) {
  return request({
    url: '/check/xw_js_bom/bomForSubmit',
    method: 'post',
    // params: query
    data: query
  })
}

//查看是否有待确认数据
export function getBomNotConfirmDatas(query) {
  return request({
    url: '/check/xw_js_bom/getBomNotConfirmDatas',
    method: 'post',
    params: query,
    data: query
  })
}

//查看是否有待确认数据
export function getReportBomNotConfirmDatas(query) {
  return request({
    url: '/check/xw_js_bom/getReportBomNotConfirmDatas',
    method: 'post',
    params: query,
    data: query
  })
}

export function waitSubmitMainOptionList() {
  return {
    emptyBtn: false,
    editBtn: false,
    delBtn: false,
    addBtn: false,
    refreshBtn: false,
    columnBtn: false,
    border: true,
    index: true,
    indexLabel: '序号',
    page: false,
    align: 'center',
    menuWidth: 150,
    height: 500,
    menuAlign: 'center',
    selection: true,
    reserveSelection: false,
    column: [ {
      label: "线路", prop: "lineCode", search: false,hide:true, searchslot: true, formatter: function (row, value, label, column) {
        return getLineName(value);
      }
      },
      {
        label: "站点",
        prop: "stationCode",
        search: true,
        searchslot: true,
        formatter: function (row, value, label, column) {
          return getStationName(row.lineCode, value);
        }
      },{
        label: "售票员",
        prop: "conductorName",
        type: 'input',
        search: true,
        searchslot: true,
        formatter: function (row, value, label, column) {
          if (row.isMergeRecord == 1) {
            return row.mergeConductorPersonName;
          }
          return value;
        }
      },
      { prop: "conductorJobNo", label: "操作员工号" },
      { prop: "deviceOperateNum", label: "设备操作号" },
      {
        prop: "preJieSuanDate", label: "上次结算日期", hide:true, type: 'date', valueFormat: 'yyyy-MM-dd', formatter: function (row, v) {
          if (!v) {
            return moment(row.settleTime).subtract(1, 'days').format('YYYY-MM-DD');
          } else {
            return moment(row.endSettleDate).format('YYYY-MM-DD');
          }
        }
      },
      { prop: "settleTime", label: "收入日期", type: 'date', valueFormat: 'yyyy-MM-dd', search: true },
      {
        prop: "dailyCashTotalAmount", label: "最晚提交日期", formatter: function (row, v) {
          if (row.settlementTerm >= 0) {
            return moment(row.settleTime).add(row.settlementTerm, 'days').format('YYYY-MM-DD');
          } else {
            return row.settleTime;
          }
        }
      },
      {
        prop: "realAmount", label: "现金实收金额", formatter: function (row, v) {
          if (v) {
            return Number(v).toFixed(2);
          }
          return v;
        }
      },
      {
        prop: "electronicAmount", label: "团购电子金额", formatter: function (row, v) {
          if (v) {
            return Number(v).toFixed(2);
          }
          return v;
        }
      },
      {
        "type": "date",
        "label": "日期范围",
        "prop": "dates1",
        hide: true,
        search:true,
        searchRange: true,
        searchSpan: 12,
        width: 90,
        format: 'yyyy-MM-dd',
        valueFormat: 'yyyy-MM-dds',
      },
    ]
  }
}

export function getPreview(row) {
  let res = {};
  res.lineCode = row.lineCode;
  res.stationCode = row.stationCode;
  res.conductorName = row.conductorName;
  res.settleTime = row.settleTime;
  res.recordTime = row.settleTime;
  res.deviceOperatorNum = row.deviceOperateNum;
  res.settleEndTime = '';
  res.conductorShifts = row.conductorShifts;
  res.cashReceiptAmount = row.realAmount;
  res.electronicAmount = row.electronicAmount;
  res.passengerAttendantJobNo = '';
  res.attendancePersonJobNo = '';
  res.conductorJobNo = row.conductorJobNo;
  res.settleStartTime = '';
  res.advanceAmount = row.adanceAmount;
  res.passengerAttendantName = '';
  res.attendancePersonName = '';
  res.yuFashouTicketNum = '';
  res.yuFashouTicketAmount = '';
  return res;
}
